package com.ihrm.modules.sys.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ihrm.common.utils.PageUtils;
import com.ihrm.common.utils.Query;

import com.ihrm.modules.sys.dao.IndustryDao;
import com.ihrm.modules.sys.entity.IndustryEntity;
import com.ihrm.modules.sys.service.IndustryService;


@Service("industryService")
public class IndustryServiceImpl extends ServiceImpl<IndustryDao, IndustryEntity> implements IndustryService {

    @Autowired
    private IndustryDao industryDao;

    public PageUtils queryPage(Map<String, Object> params) {
        IPage<IndustryEntity> page = this.page(
                new Query<IndustryEntity>().getPage(params),
                new QueryWrapper<IndustryEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<IndustryEntity> subData(Integer id) {
        return new LambdaQueryChainWrapper<>(industryDao)
                .eq(IndustryEntity::getParentId, id)
                .list();
    }
}
